package com.zsrt.java.day20161226.wrl.demo03;

public class Work10 {
	
	/**
	 * 用while打印99乘法表，用都do while打印99乘法表
	 */
	/*@Test
	public void w10forWhile(){
		int index1 = 1;
		while(index1 <= 9){
			int index2 = 1;
			while(index2 <= index1){
				System.out.print(index1 + "x" + index2 + "=" + index1 * index2 + "\t");
				index2++;
			}
			System.out.println();
			index1++;
		}
	}*/
	/*@Test
	public void w10forDoWhile(){
		int index1 = 1;
		do{
			int index2 = 1;
			do{
				System.out.print(index2 + "x" + index1 + "=" + index1 * index2 + "\t");
				index2++;
			}while(index2 <= index1);
			System.out.println();
			index1++;
		}while(index1 <= 9);
	}*/
	/*
	@Test
	public void w10fan() {
		for (int index1 = 1; index1 <= 9; index1++) {
			for (int index2 = 1; index2 <= 10 - index1; index2++) {
				System.out.print(index2 + "x" + index1 + "=" + index1 * index2 + "\t");
			}
			System.out.println();
		}
	}*/
	
	public static void main(String[] args) {
//		work10forWhile(9);
//		work10forDoWhile(9);
		work10Reverse(9);
	}

	public static void work10forWhile(int number){
		int index1 = 1;
		while(index1 <= number){
			int index2 = 1;
			while(index2 <= index1){
				System.out.print(index1 + "x" + index2 + "=" + index1 * index2 + "\t");
				index2++;
			}
			System.out.println();
			index1++;
		}
	}
	
	public static void work10forDoWhile(int number){
		int index1 = 1;
		do{
			int index2 = 1;
			do{
				System.out.print(index2 + "x" + index1 + "=" + index1 * index2 + "\t");
				index2++;
			}while(index2 <= index1);
			System.out.println();
			index1++;
		}while(index1 <= number);
	}
	
	public static void work10Reverse(int number) {
		for (int index1 = 1; index1 <= number; index1++) {
			for (int index2 = 1; index2 <= number+1 - index1; index2++) {
				System.out.print(index2 + "x" + index1 + "=" + index1 * index2 + "\t");
			}
			System.out.println();
		}
	}
}
